package com.puppy.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

//@WebFilter("/*")// 设置拦截路径，拦截所有请求
@Slf4j
public class DxemoFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
//        Filter.super.init(filterConfig);
        log.info("过滤器初始化");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        //拦截
        log.info("过滤器执行了");
        //请求合法，则放行
        chain.doFilter(request,response);
        log.info("过滤器放行");
        log.info("过滤器执行完毕");

    }

    @Override
    public void destroy() {
//        Filter.super.destroy();
        log.info("过滤器销毁");
    }
}
